<template>
  <a-modal
    :title="title"
    :width="1200"
    :visible="visible"
    switchFullscreen
    :footer="null"
    @cancel="handleCancel()"
    :maskClosable="false"
    cancelText="关闭"
  >
    <!-- table区域-begin -->
    <div>
      <a-table
        :columns="columns"
        :data-source="data"
        bordered
        :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
        rowKey="id"
        :pagination="false"
        :loading="loading"
        :scroll="{ y: 700 }"
        @change="handleTableChange"
        style="margin-top: 20px;"
      >
      </a-table>
    </div>
  </a-modal>
</template>

<script>
  import { httpAction, getAction,postAction ,postActionAsync} from '@/api/manage'

  export default {
    name: 'standardModal',
    components: {},
    props:{
      projectBuildId:{
        type:String ,
        required: true
      }
    } ,
    data() {
      return {
        classId: 4,
        columns: [
          {
            title: '团队成员',
            dataIndex: 'memberRealName',
            align: 'center' ,
            key: 'memberRealName'
          },
          {
            title: '成员账号',
            dataIndex: 'memberUserName',
            align: 'center' ,
            key: 'memberUserName',
            scopedSlots: { customRender: 'memberUserName' }
          },
          {
            title: '所在部门',
            dataIndex: 'memberDeptName',
            width:200 ,
            align: 'center' ,
            key: 'memberDeptName'
          },
          {
            title: '累计投入(万元)',
            dataIndex: 'manDays',
            align: 'center' ,
            key: 'manDays'
          },
          {
            title: '本月投入(万元)',
            dataIndex: 'thisMonthManDay' ,
            align: 'center' ,
            key:'thisMonthManDay'
          }

        ],
        title: '项目成本反馈',

        visible: false,

        data: [],
        selectedRowKeys: [],
        selectionRows: [],
        rowKeyIndex: -1,
        /* 分页参数 */
        ipagination: {
          current: 1,
          pageSize: 10,
          pageSizeOptions: ['10', '20', '30'],
          showTotal: (total, range) => {
            return range[0] + '-' + range[1] + ' 共' + total + '条';
          },
          showQuickJumper: true,
          showSizeChanger: true,
          total: 0,
          name: '',
          keywords: ''
        },
        standardType: 1,
        loading: false,
        url: {
          list: '/projectBuildManday/list',
          riskList: '/standardInfo/listStandard'
        }
      };
    },
    methods: {
      add() {
        this.visible = true;
        this.loadList();
      },

      close() {
        this.$emit('close');
        this.visible = false;
      },
      handleCancel() {
        this.close();
      },

      handleChange(value, index, column) {
        this.$set(this.data[index], column, value);
      },
      handleAdd() {
        debugger;
        this.data.push({ id: this.rowKeyIndex, name: '', required: false, sort: '' });
        this.rowKeyIndex--;
      },
      loadList() {
        debugger
        this.loading = true;
        let param = {}
        this.$set(param , 'projectBuildId' , this.projectBuildId)
        const that = this;
        getAction(this.url.list, param).then(res => {
          if (res.code == 200) {
            that.data = res.result
            this.loading = false;
          }

        });

      },
      handleOK() {
        if (this.selectedRowKeys.length <= 0) {
          this.$message.warning('请选择一条记录！');
          return;
        }
        this.$emit('addRelationTags');
        this.visible = false;
      },

      onSelectChange(selectedRowKeys, selectionRows) {
        this.selectedRowKeys = selectedRowKeys;
        this.selectionRows = selectionRows;
      },
      handleTableChange(pagination, filters, sorter) {
        this.ipagination = pagination;
        this.ipagination.pageNo = this.ipagination.current;
        this.loadList();
      },
      handleTypeChange(val) {
        this.standardType = val;
        this.loadList();
      }
    }
  };
</script>
